
scan = 4;
path = ['G:\Stacks\Overview.OverView\1.Experiment\Experiment Data\Tile Scan (' num2str(scan) ')\'];
file = ['1.Tile Scan (' num2str(scan) ').Tile_' ];
x1 = 1:1024:1024*4;
y1 = x1;
% tileseq = [3 4 1 2 6 5]; % 2
% tileseq = [4 3 1 2 5 6]; %6
tileseq = [5 6 1 2 3 4]; %4
tiles2 = zeros(1024*3,1024*2,3);
i = 1;
for ind = 1:3
    for jnd = 1:2
      pathfile = [path file num2str(tileseq(i)) '.lsm'];
      data = load_lsm(pathfile);
      if i == 1 
          dim = size(data);
      end
      tiles2(x1(ind):x1(ind+1)-1,y1(jnd):y1(jnd+1)-1,1) = max(data(:,:,1:3:dim(3)),[],3);
      tiles2(x1(ind):x1(ind+1)-1,y1(jnd):y1(jnd+1)-1,2) = max(data(:,:,2:3:dim(3)),[],3); 
      tiles2(x1(ind):x1(ind+1)-1,y1(jnd):y1(jnd+1)-1,3) = max(data(:,:,3:3:dim(3)),[],3); 
      i = i + 1;
    end
end

figure;imagesc(tiles2./255);
